package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author DN
 * @description:政治面貌编码映射枚举类CD000002
 * @date 2023/11/30 10:06
 */
public enum PoliticalAffiliation implements KeyValueMap {
    CCP_MEMBER("01", "中国共产党党员"),
    CCP_PROBATIONARY_MEMBER("02", "中国共产党预备党员"),
    CYL_MEMBER("03", "中国共产主义共青团团员"),
    KMT_REVOLUTIONARY_COMMITTEE_MEMBER("04", "中国国民党革命委员会会员"),
    DEMOCRATIC_ALLIANCE_MEMBER("05", "中国民主同盟盟员"),
    DEMOCRATIC_NATION_BUILDING_ALLIANCE_MEMBER("06", "中国民主建国会会员"),
    DEMOCRATIC_PROMOTION_ALLIANCE_MEMBER("07", "中国民主促进会会员"),
    NGD_MEMBER("08", "中国农工民主党党员"),
    ZGD_MEMBER("09", "中国致公党党员"),
    JIUSAN_SOCIETY_MEMBER("10", "九三学社社员"),
    TAIWAN_AUTONOMY_ALLIANCE_MEMBER("11", "台湾民主自治同盟盟员"),
    NON_PARTISAN_DEMOCRATIC_INDIVIDUAL("12", "无党派民主人士"),
    MASSES("13", "群众"),
    OTHER("99", "其他");

    private String code;
    private String name;

    PoliticalAffiliation(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return name;
    }

    public static PoliticalAffiliation getValueByKey(String key) {
        for (PoliticalAffiliation politicalAffiliation : values()) {
            if (politicalAffiliation.code.equals(key)) {
                return politicalAffiliation;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

    public static PoliticalAffiliation getKeyByValue(String value) {
        for (PoliticalAffiliation politicalAffiliation : values()) {
            if (politicalAffiliation.name.equals(value)) {
                return politicalAffiliation;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}
